package com.example.emergencyattempt01.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.viewpager.widget.PagerAdapter;

import java.util.List;

public class ReturnBook_Pager_Adapter extends PagerAdapter {
    Context context;
    List<View> viewList;
    List<String> titleList;

    public ReturnBook_Pager_Adapter(Context context, List<View> viewList, List<String> titleList) {
        this.context = context;
        this.viewList = viewList;
        this.titleList = titleList;
    }

    @Override
    public int getCount() {
        return viewList.size();
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view==object;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        container.addView(viewList.get(position));
        return viewList.get(position);
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView(viewList.get(position));
    }


    @Override
    public CharSequence getPageTitle(int position) {
        return titleList.get(position);
    }
}
